<?php
class Color
{
	public $Table="color";
	public $conn;
	public $data=array();
	public $item=array();
	private $field=array(
					 "ItemID",
					 "ColorName",
					 "Icon",
					 "IconPath",
					 "ImageID",
					 "ImagePath",
					 "`Group`"
					 );
	public $group = array(
						  "1" => "The Granite Metallic Family",
						  "2" => "The Granite Family",
						  );
	
	public function __construct($conn) 
	{
    	$this->conn=$conn;
		$obj1=new Info();
		$obj1->loadByKey("group_1");
		$obj2=new Info();
		$obj2->loadByKey("group_2");
		$this->group["1"] = $obj1->InfoName;
		$this->group["2"] = $obj2->InfoName;
   	}
	
	function getItem($id)
	{	
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` WHERE  AND ID = '".$id."'";
		$data=$ob->mutiData($sql);
		$this->item=$data[0];
	}
	
	function getTable($dk)
	{
		$ob=new ClassConnect();
		$sql="select * from `".$this->Table."` WHERE 1=1 $dk";
		$this->data=$ob->mutiData($sql);
		
	}
	
	function insert($data)
	{
		$ob=new ClassConnect();
		$value = array();
		foreach($this->field as $item)
		{
			$value[] = $data[$item];
		}
		$this->SupportID=$ob->getNextId($this->Table,"ID");
		
		
		return $ob->insertData($this->conn,$this->Table,$this->field,$value);
	}
	
	function update($data)
	{
		$ob=new ClassConnect();
		
		$value = array();
		foreach($this->field as $item)
		{
			$value[] = $data[$item];
		}
		
		$where="ID";
		$wherevalue=$data['ID'];
		return $ob->updateData($this->conn,$this->Table,$this->field,$value,$where,$wherevalue);			
	}
	
	function delete($id)
	{
		$ob=new ClassConnect();	
		$where="ID";
		$wherevalue=$id;
		return $ob->deleteData($this->conn,$this->Table,$where,$wherevalue);
			
	}

}
?>
